package cn.tworice.common.utils;


import cn.tworice.common.entity.Admin;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;

public class TokenUtil {
    public static String getAdminToken(Admin admin){
        Long time=System.currentTimeMillis()+(1000*60*60*24);
        Date date = new Date();
        date.setTime(time);
        String token= JWT.create().withAudience(admin.getId()).withExpiresAt(date)// 将用户ID存入token中
                .sign(Algorithm.HMAC256(admin.getId()));// 设置用户ID为IP地址

        return token;
    }
}
